package com.etl.plugin.datasource.sqlexecute.impl;

import com.etl.plugin.datasource.admin.DataBasePoolContainer;
import com.etl.plugin.datasource.sqlexecute.abs.AbsSqlExecute;

import javax.xml.crypto.Data;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * mysql执行器类
 */
public class MySqlExecute extends AbsSqlExecute {

    //载入线程池
    private ThreadLocal<Connection> threadLocal = new ThreadLocal<>();

    /**
     * 获取
     */
    @Override
    public void pool(String connId) {
        //
        Connection conn = DataBasePoolContainer.getConn(connId, Connection.class);

        threadLocal.set(conn);
    }

    /**
     * 归还
     */
    @Override
    public void back(String connId) {
        Connection connection = threadLocal.get();
        DataBasePoolContainer.backConn(connId,connection);
    }


    /**
     * sql执行 连接池创建
     * @return
     */
    @Override
    public String sqlExcute() {
        //        Connection connection = threadLocal.get();
        //        PreparedStatement preparedStatement = connection.prepareStatement("");
        //        ResultSet resultSet = preparedStatement.executeQuery();

        return null;
    }
}
